<?php

	//接收ID
	$id = $_GET['id'];

	//连接数据
	include '../include/common.php';

	//抓取数据的语句
	$query = "SELECT id,name,author,public,price,catagory,description,photo,dt FROM book WHERE ishow=1 AND id=$id";

	//执行语句
	$result = mysqli_query($conn,$query);

	//从结果记录集中以数组的形式抓取出来
	$res = mysqli_fetch_array($result);

	$name = $res['name'];
	$author = $res['author'];
	$public = $res['public'];
	$price = $res['price'];
	$catagory = $res['catagory'];
	$description = $res['description'];
	$photo = $res['photo'];
	$dt = $res['dt'];

	//分类
	switch ($catagory) {
		case 7:
			$cname = 'web前端';
			break;
		
		case 1:
			$cname = 'PHP';
			break;

		case 2:
			$cname = 'nodejs';
			break;
			
		default:
			# code...
			break;
	}

	if (!$name){
		echo '抱歉，该信息不能显示！';
	} else {

		echo 
		'
			<table>
				<tr><td width="10%"></td><td width="90%"></td></tr>
				<tr><td>书名：</td><td>'.$name.'</td></tr>
				<tr><td>作者：</td><td>'.$author.'</td></tr>
				<tr><td>出版社：</td><td>'.$public.'</td></tr>
				<tr><td>价格：</td><td>'.$price.'</td></tr>
				<tr><td>分类：</td><td>'.$cname.'</td></tr>
				<tr><td>描述：</td><td>'.$description.'</td></tr>
				<tr><td>图片：</td><td><img src="../'.$photo.'"></td></tr>
				<tr><td>上架日期：</td><td>'.date('Y-m-d',$dt).'</td></tr>
			</table>

		';

	}

	//添加html
	
?>